﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Collections;
using System.ComponentModel;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Text;
using System.Transactions;
using WebServiceSmart.Router;
using Thrift.Transport;
using Thrift.Protocol;
using Thrift.Route;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using log4net;
using System.Security.Cryptography;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Threading;
using WebServiceSmart.Model;

namespace WebServiceSmart
{
    public partial class MyService
    {
        public static string BIAOPRINTERCFG = "qgcomprinterconfig";


        //用户获取云打印机配置
        [WebMethod(Description = "正式版本")]
        public string xcx_yonghugetprintercfg(string msg)
        {
            ILog logJieKou = LogManager.GetLogger("LoggerZhiFu");
            ComThriftMsg ret = new ComThriftMsg();
            ret.Byte_Flag = (sbyte)-1;
            ret.Map_Args = new Dictionary<string, string>();
            ret.Map_Args.Add("ErrorMsg", "服务器异常");
            byte[] bytrcv = Convert.FromBase64String(msg);
            ComThriftMsg comrcv = CommonTools.Json_ByteTOComThriftAESD(bytrcv);
            mysqlcli mainsql = new mysqlcli();

            try
            {
                string companyaccount = comrcv.Map_Args["companyaccount"];
                string companynetaccount = comrcv.Map_Args["companynetaccount"];
     

                logJieKou.Info("用户获取云打印机配置-" + companyaccount);
                mainsql.openYongHuServicesql();

                string sqlcmd = string.Format("SELECT * FROM {0} " +
                    " where qgcfg_companyaccount ='{1}' AND qgcfg_companynetaccount='{2}'  ;",
                    BIAOPRINTERCFG, companyaccount, companynetaccount);
                DataTable ds = mainsql.SqlExcuteWithReturn(sqlcmd);
                mainsql.closesql();
                ret.Map_Args.Add("AllCount", ds.Rows.Count.ToString());
                ret.List_MapArgs = new List<Dictionary<string, string>>();
                if (ds.Rows.Count != 0)
                {
                    foreach (DataRow row in ds.Rows)
                    {
                        Dictionary<string, string> newNetImple = new Dictionary<string, string>();
                        foreach (DataColumn dl in ds.Columns)
                        {
                            newNetImple.Add(dl.ColumnName, row[dl.ColumnName].ToString());
                        }
                        ret.List_MapArgs.Add(newNetImple);
                    }
                }
                ds.Dispose();
            }
            catch (Exception ex)
            {
                logJieKou.Info("用户获取云打印机配置-" + ex.Message);
                mainsql.closesql();

                goto EXIT;
            }
            ret.Byte_Flag = (sbyte)1;
        EXIT:
            byte[] retb = CommonTools.Json_ComThriftTOByteAESE(ret);
            string retstr = Convert.ToBase64String(retb);
            return retstr;

        }


    }
}